﻿<?php
$servername='localhost';
$user_name='root';
$password='root';
$db_name='test';
try{
	$conn_pdo=new PDO("mysql:host=$servername;dbname=$db_name",$user_name,$password);
	 // 设置 PDO 错误模式为异常
    $conn_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	
	$stmt=$conn_pdo->prepare("insert into test_user_info (`user_id`,`age`,`tel`) values (:user_id,:age,:tel)");
	
	$stmt->bindParam(':user_id',$user_id);
	$stmt->bindParam(':age',$age);
	$stmt->bindParam(':tel',$tel);
	$user_id=56;
	$age=11;
	$tel='13288879997';
	$stmt->execute();
	
	
	
	$user_id=12;
	$age=21;
	$tel='13288879997';
	$stmt->execute();
	
	
	
	
	$user_id=15;
	$age=36;
	$tel='13288879997';
	$stmt->execute();
	echo '插入成功';
}catch(PDOException $e){
      echo $e->getMessage();	
}
$conn = null;